package com.example.newsdemo;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;
import java.util.zip.Inflater;

/**
 * Created by 谢汉荣 on 2018/5/26.
 */

public class CommentsSectionAdapter extends RecyclerView.Adapter<CommentsSectionViewHolder>{
    private List<Comment> comment;
    private Context context;

    public CommentsSectionAdapter(Context context,List<Comment> comment) {
        this.context = context;
        this.comment = comment;
    }
    @Override
    public CommentsSectionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.morecomments_list_item,parent,false);
        CommentsSectionViewHolder holder = new CommentsSectionViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(CommentsSectionViewHolder holder, int position) {
    final Comment dataBean = comment.get(position);
    holder.tvUserID.setText(dataBean.getUser_id());
    holder.tvCotent.setText(dataBean.getContent());

    }

    @Override
    public int getItemCount() {
        if (comment == null) {
            return 0;
        }
        return comment.size();
    }

    public void changData(List<Comment> comment) {
        this.comment = comment;
        notifyDataSetChanged();

    }
}
